<template>
  <div class="container">
    <ul>
      <li v-for="(item, index) in incomeDataList" v-if="parseInt(item.bonus) > 0" :key="index">
        <div class="month_tit">
          <p class="month">
            {{ item.month
            }}<img
              class=""
              src="@/assets/车主宝首页改-assets/返回.png"
              alt=""
            />
          </p>
          <p class="month_income">月收益：￥{{ item.bonus }}</p>
        </div>
        <incomeItem :item="item.detail"></incomeItem>
      </li>
    </ul>
    <load-more @loadMore="loadMore"></load-more>
  </div>
</template>

<script>
import incomeItem from "./component/income-item.vue";
import loadMore from "@/components/load-more";
import { getIncomeList } from "@/api/vip";
export default {
  data() {
    return {
      incomeDataList: [],
      page: 1,
      isAll: false,
      loading: false
    };
  },
  methods: {
    getIncomeList(page) {
      getIncomeList({ page }).then(res => {
        if (res.status === 200) {
          this.incomeDataList.push(...res.data.data);
          if (res.data.data.length === 0) {
            this.isAll = true;
            this.$dialog.toast({
              mes: "已经到最底了",
              timeout: 1000
            });
          }
        }
        this.loading = false;
      });
    },
    loadMore() {
      if (this.loading || this.isAll || this.incomeDataList.length === 0)
        return;
      this.loading = true;
      this.getIncomeList(++this.page);
    }
  },
  components: {
    incomeItem,
    loadMore
  },
  created() {
    this.getIncomeList(1);
  }
};
</script>

<style lang="less" scoped>
.container {
  min-height: 100%;
  height: auto;
  .clear {
    clear: both;
  }
  .month_tit {
    padding: 0.6rem 0.5rem;
    .month {
      color: #444444;
      font-size: 0.56rem;
      margin-bottom: 0.3rem;
    }
    .month img {
      width: 0.25rem;
      margin: 0 0 0 0.4rem;
      transform: rotate(90deg);
    }
    .month_income {
      color: #999999;
      font-size: 0.48rem;
    }
  }
}
</style>
